import BaseModal from ".";

export interface InfoModalProps {
  info?: string;
  type?: string; // type === "delete" ? "删除" : "拒绝"
  isModalOpen?: boolean;
  handleOpenModal?: (paramsId: any) => void;
  handleCloseModal?: () => void;
  handleConfirm?: () => void;
}

const Child = ({ info }: { info: string }) => {
  return (
    <div
      style={{
        height: "80px"
      }}
    >
      <div
        style={{
          display: "flex",
          justifyContent: "center",
          alignItems: "center",
          textAlign: "center",
          height: "80px",
          lineHeight: "80px"
        }}
      >
        {info}
      </div>
    </div>
  );
};

/** 仅展示信息的 Modal
 * 抽出来是否会更简单呢 对一些只展示信息的 比如 同意拒绝 是否删除某某某
 */
const InfoModal = (props: InfoModalProps) => {
  const {
    info,
    type,
    handleOpenModal,
    handleCloseModal,
    handleConfirm,
    isModalOpen
  } = props;

  /** 信息modal的参数 */
  const InfoProps = {
    isModalOpen,
    handleConfirm,
    handleOpen: () => handleOpenModal,
    handleClose: () => handleCloseModal!(),
    ModalChildren: () => <Child info={info as string} />,
    sumbitButtonName: type === "delete" ? "删除" : "确认"
  };
  return (
    <>
      <BaseModal {...InfoProps} />
    </>
  );
};

export default InfoModal;
